﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;
namespace BLL.Sec
{
    /// <summary>
    /// 用户组类
    /// </summary>
    public class UserGroup
    {
        private readonly OracleDAL.Sec.UserGroup dal = new OracleDAL.Sec.UserGroup();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="SortExpression">可以为空</param>
        /// <param name="SortDirection">可以为空</param>
        /// <param name="isRoots">是否为根用户</param>
        /// <returns></returns>
        public List<Model.Sec.UserGroup> GetAll(string SortExpression, string SortDirection, bool isRoots)
        {
            return dal.GetAll(SortExpression, SortDirection,isRoots);
        }
        /// <summary>
        /// 返回MODEL
        /// </summary>
        /// <param name="UserGroupISN">条件</param>
        /// <returns></returns>
        public Model.Sec.UserGroup GetModel(string UserGroupISN)
        {
            return dal.GetModel(UserGroupISN);
        }
        public Model.Sec.UserCollection GetUsers(string UserGroupISN)
        {
            Model.Sec.UserGroup ug = new Model.Sec.UserGroup();
            ug.UserGroupISN = UserGroupISN;
            return ug.Users;
        }

        #region 新增用户组，静态方法
        /// <summary>
        /// 新增用户组
        /// </summary>
        /// <param name="userGroup">用户组对象</param>
        /// <returns>新增是否成功</returns>
        public bool NewUserGroup(Model.Sec.UserGroup userGroup)
        {
            return dal.NewUserGroup(userGroup);
        }
        #endregion

        #region 更新用户组资料，实例方法
        /// <summary>
        /// 更新用户组资料
        /// </summary>
        /// <param name="userGroup">用户组对象</param>
        /// <returns>更新是否成功</returns>
        public bool Update(Model.Sec.UserGroup userGroup)
        {
            return dal.Update(userGroup);
        }
        #endregion

        #region 删除用户组，静态方法和实例方法
        /// <summary>
        ///  删除用户组,用户组权限
        /// </summary>
        /// <param name="UserGroupISN">用户组ISN</param>
        /// <returns>删除是否成功</returns>
        public bool Delete(string UserGroupISN)
        {
            return dal.Delete(UserGroupISN);
        }
        /// <summary>
        /// 删除用户组
        /// </summary>
        /// <param name="userGroup">用户组对象</param>
        /// <returns>删除是否成功</returns>
        public bool Delete(Model.Sec.UserGroup userGroup)
        {
            return dal.Delete(userGroup.UserGroupISN);
        }
        #endregion
        /// <summary>
        /// 返回查到的记录数
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public Int64 getCount(string strWhere)
        {
            return dal.GetCount(strWhere);
        }
        /// <summary>
        /// 增加一条数据,并且给用户组增加OperateID
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool add(Model.Sec.UserGroup model)
        {
            return dal.add(model);
        }
        /// <summary>
        /// 根据用户的ISN查询所在的用户组model
        /// </summary>
        /// <param name="UserISN"></param>
        /// <returns></returns>
        public Model.Sec.UserGroup[] getByUserISN(string UserISN)
        {
            return dal.getBYUser(UserISN);
        }
        /// <summary>
        /// 更新用户组权限
        /// </summary>
        /// <param name="UserGroupISN"></param>
        /// <param name="OperateIDs">OperateIDs逗号分开，最后一个不用跟着逗号</param>
        /// <param name="Enable"></param>
        /// <returns></returns>
        public bool updateOperate(string UserGroupISN, string OperateIDs, string Enable)
        {
            return dal.update(UserGroupISN, OperateIDs, Enable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public Model.Sec.UserGroup[] getModels(string strWhere)
        {

            return dal.getModels(strWhere);
        }
        public DataSet getTotalUserGroup()
        {
            DataSet ds = new DataSet();
            ds = dal.getTotalUserGroup();
            return ds;
        }
        public int insertScreen(string usergroupisn, string screen, string rootOperate, string childOperate, string type)
        {
            int result = dal.insertScreen(usergroupisn, screen, rootOperate, childOperate, type);
            return result;
        }
        public int updateScreen(string usergroupisn,string s1,string s2)
        {
            int result = dal.updateScreen(usergroupisn, s1, s2);
            return result;
        }
        public DataSet  setScreen(string usergroup)
        {
            DataSet ds = new DataSet();
            ds = dal.setScreen(usergroup);
            return ds;

        }
    }
}
